asm
  ld sp,$A7FF
  end asm

#include "./library/smsdelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $A010
dim seed as uinteger at $A012
dim ee0 as uinteger at $A018
dim ee1 as uinteger at $A01A
dim ee2 as uinteger at $A014
dim ee3 as uinteger at $A016
dim ex0 as uinteger at $A020
dim ey0 as uinteger at $A022

seed=0

sub kusayakyuuputchat(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $B001+((typ1 bxor 31)*64)+(txp1*2),tch1
  poke $B000+((typ1 bxor 31)*64)+(txp1*2),tat1
  end sub



for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    kusayakyuuputchat(ee1,ee0,seed band 7,ee2 band 240)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    kusayakyuuputchat(ee1+15,ee0+13,ee0*16+ee1,0)
    next:next

ex0=9:ey0=9
eee=0
do
kusayakyuuputchat(1,3,48+(int(eee/10000) mod 10),0)
kusayakyuuputchat(2,3,48+(int(eee/1000) mod 10),0)
kusayakyuuputchat(3,3,48+(int(eee/100) mod 10),0)
kusayakyuuputchat(4,3,48+(int(eee/10) mod 10),0)
kusayakyuuputchat(5,3,48+(eee mod 10),0)

ee0=peek($A800)
kusayakyuuputchat(3,5,48+(int(ee0/100) mod 10),0)
kusayakyuuputchat(4,5,48+(int(ee0/10) mod 10),0)
kusayakyuuputchat(5,5,48+(ee0 mod 10),0)

ex0=ex0+((ee0 band 1)/1)-((ee0 band 2)/2)
ey0=ey0+((ee0 band 4)/4)-((ee0 band 8)/8)
kusayakyuuputchat(ex0,ey0,eee band 127,0)

ee0=peek($A801)
kusayakyuuputchat(3,6,48+(int(ee0/100) mod 10),0)
kusayakyuuputchat(4,6,48+(int(ee0/10) mod 10),0)
kusayakyuuputchat(5,6,48+(ee0 mod 10),0)

ee0=peek($A802)
kusayakyuuputchat(3,7,48+(int(ee0/100) mod 10),0)
kusayakyuuputchat(4,7,48+(int(ee0/10) mod 10),0)
kusayakyuuputchat(5,7,48+(ee0 mod 10),0)




eee=eee+1
loop






do:loop






'static ADDRESS_MAP_START( maincpu_map, AS_PROGRAM, 8, ksayakyu_state )
'AM_RANGE(0x0000, 0x3fff) AM_ROM
'AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
'AM_RANGE(0x8000, 0x9fff) AM_ROM
'AM_RANGE(0xa000, 0xa7ff) AM_RAM
'AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P1")
'AM_RANGE(0xa801, 0xa801) AM_READ_PORT("P2")
'AM_RANGE(0xa802, 0xa802) AM_READ_PORT("DSW")
'AM_RANGE(0xa803, 0xa803) AM_READNOP /* watchdog ? */
'AM_RANGE(0xa804, 0xa804) AM_WRITE(ksayakyu_videoctrl_w)
'AM_RANGE(0xa805, 0xa805) AM_WRITE(latch_w)
'AM_RANGE(0xa806, 0xa806) AM_READ(sound_status_r)
'AM_RANGE(0xa807, 0xa807) AM_READNOP /* watchdog ? */
'AM_RANGE(0xa808, 0xa808) AM_WRITE(bank_select_w)
'AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(ksayakyu_videoram_w) AM_SHARE("videoram")
'AM_RANGE(0xb800, 0xbfff) AM_RAM AM_SHARE("spriteram")
'ADDRESS_MAP_END






